package com.peng.leetcode.other;

/**
 * AddTwoNumbers
 *
 * @author: lupeng6
 * @create: 2020/10/4 18:49
 */
public class AddTwoNumbers {

    public static void main(String[] args) {

    }

    static class Solution {
        public ListNode addTwoNumbers(ListNode l1, ListNode l2) {
            boolean flag = false;
            ListNode current = null;;
            int sum = l1.val + l2.val;

            if (sum > 10) {
                flag = true;
                current = new ListNode(sum % 10);
            } else {
                current = new ListNode(sum);
            }
            current.next = addTwoNumbers(l1.next, l2.next);
            return current;
        }
    }

    static public class ListNode {
        int val;
        ListNode next;

        ListNode(int x) {
            val = x;
        }
    }
}
